import './public-path'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import  helloCom  from 'hello-com-test'
import 'hello-com-test/styles/helloCom.css'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(helloCom)
// 应用每次渲染时都会执行 mount 方法，在此处可以执行初始化相关操作（必传)
let app
export async function mount (props) {
  app = new Vue({
    router,
    store,
    render: h => h(App)
  }).$mount(props?.container?.querySelector('#app1') || '#app1')
}

// 卸载应用
export async function unmount () {
  console.log('vue2卸载了')
  app.$destroy()
  app.$el.innerHTML = ''
  app = null
}

export async function bootstrap () {

}

// 微前端环境下，注册mount和unmount方法
if (window.__MICRO_APP_ENVIRONMENT__) {
  window[`micro-app-${window.__MICRO_APP_NAME__}`] = { mount, unmount }
} else {
  // 非微前端环境直接渲染
  mount()
}
